package com.ruoyi.system.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 用户得分Mapper接口
 *
 * @author ruoyi
 * @date 2024-11-18
 */
public interface UserScoreMapper {

    /**
     * 查询用户得分的能力评分
     */
    @Select("SELECT u.score,ro.content_Name,ro.grade,ra.category_Name,ro.category\n" +
            "FROM user_score u,rating_category ra,rating_content ro,sys_user s\n" +
            "WHERE ra.category_Id=ro.category\n" +
            "AND u.category_id=ro.content_Id\n" +
            "AND s.user_id=u.user_id\n" +
            "AND ra.parent_Id=#{parentId}\n" +
            "AND s.user_id=#{userId}\n" +
            "AND u.assess_Date LIKE concat('%',#{time},'%')" +
            "AND QUARTER(u.assess_Date)=#{quarter}")
    List<Map> selectUserScoreByUserId(Map map);

    /**
     * 查询用户得分的总数
     *
     * @return
     */
    @Select("SELECT\n" +
            "COUNT(1) AS count \n" +
            "FROM\n" +
            "evaluation_Status es,\n" +
            "sys_user su,\n" +
            "sys_role sr,\n" +
            "sys_user_role sur \n" +
            "WHERE\n" +
            "su.user_id = es.rater_num \n" +
            "AND es.user_id = #{userId} \n" +
            "AND QUARTER ( es.assess_Date )= #{quarter} \n" +
            "AND es.assess_Date LIKE concat('%',#{time},'%') \n" +
            "AND sr.role_id = sur.role_id \n" +
            "AND su.user_id = sur.user_id")
    Double selectBygcjcsum(Map map);

    @Select("SELECT ro.content_Name,ro.category,ro.grade,ra.category_Name\n" +
            "FROM rating_content ro,rating_category ra\n" +
            "WHERE ro.category=ra.category_Id\n" +
            "AND ra.parent_Id=#{parentId}")
    List<Map> selectUserScoreByUserId2(Integer parentId);

    /**
     * 查询用户昵称
     */
    @Select("SELECT u.nick_name,r.role_id,r.role_name \n" +
            "\tFROM sys_user u,sys_role r,sys_user_role ur \n" +
            "\tWHERE\n" +
            "\tu.user_id=ur.user_id\n" +
            "\tAND r.role_id=ur.role_id\n" +
            "\t AND u.user_id=#{userId}")
    Map selectUserIdByNickname(Integer userId);

    /**
     * 报表详情
     * *
     */
    @Select("SELECT\n" +
            "\tu.score,\tro.content_Name,\tra.parent_Id,\tra.category_Name\n" +
            "FROM\n" +
            "\tuser_score u,rating_category ra,rating_content ro,sys_user s \n" +
            "WHERE\n" +
            "\tra.category_Id = ro.category \n" +
            "\tAND u.category_id = ro.content_Id \n" +
            "\tAND s.user_id = u.user_id \n" +
            "\tAND s.user_id = #{userId} \n" +
            "\tAND MONTH ( u.assess_Date ) = #{month} \n" +
            "\tAND YEAR ( u.assess_Date )= #{year}")
    List<Map> selectallxiang(Map map);


    //算出谁给这个人评价的人名
    @Select("SELECT nick_name FROM sys_user WHERE user_id in (\n" +
            "SELECT rater_num FROM user_score us,sys_user su\n" +
            "WHERE us.user_id=su.user_id\n" +
            "AND MONTH ( us.assess_Date ) = #{month} \n" +
            "AND YEAR ( us.assess_Date )= #{year} \n" +
            "AND us.user_id=#{userId}\n" +
            "GROUP BY us.rater_num)")
    List<String> selectByjcName(Map map);

    //算出谁给这个人评价的id
    @Select("SELECT user_id FROM sys_user WHERE user_id in (\n" +
            "SELECT rater_num FROM user_score us,sys_user su\n" +
            "WHERE us.user_id=su.user_id\n" +
            "AND MONTH ( us.assess_Date ) = #{month} \n" +
            "AND YEAR ( us.assess_Date )= #{year} \n" +
            "AND us.user_id=#{userId}\n" +
            "GROUP BY us.rater_num)")
    List<Long> selectByjcCount1(Map map);

    //根据id查询权限职位

    List<Map> selectUserId(@Param("userids")List<Long> userids);

    @Select("SELECT\n" +
            "\tsys_user.user_id, \n" +
            "\tsys_user.nick_name, \n" +
            "\tsys_dept.dept_id, \n" +
            "\tsys_dept.dept_name, \n" +
            "\tsys_role.role_id, \n" +
            "\tsys_role.role_name\n" +
            "FROM\n" +
            "\tsys_role,\n" +
            "\tsys_user,\n" +
            "\tsys_user_role,\n" +
            "\tsys_dept\n" +
            "WHERE\n" +
            "\tsys_role.role_id = sys_user_role.role_id AND\n" +
            "\tsys_user.user_id = sys_user_role.user_id AND\n" +
            "\tsys_dept.dept_id = sys_user.dept_id AND\n" +
            "\tsys_user.user_id = #{userId} AND"+"\tsys_user.`status` = 0")
    Map selectUserIdgaoceng(Long userId);

    List<Map> selectBylist(Map map);
}
